﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="HomeDMSObjectModel" namespace="HomeDMSObjectModel">
  <class name="Page">
    <id name="PageId" column="page_id" type="System.Int32">
      <generator class="identity"/>
    </id>
    <property name="Image" column="page_image" type="BinaryBlob" access="HomeDMSObjectModel.ImageAccessor, HomeDMSObjectModel"/>
    <many-to-one name="Document" column="document_id" class="HomeDMSObjectModel.Document, HomeDMSObjectModel"/>
    <property name="Name" column="page_name" type="String"/>
    <property name="IsDefault" column="is_default" type="boolean"/>
  </class>
  <class name="Document">
    <id column ="document_id" name="DocumentId">
      <generator class="identity"/>
    </id>
    <property name="Description" column="document_description" type="String"/>
    <property name="From" column="document_from" type="System.DateTime"/>
    <property name="To" column="document_to" type="System.DateTime"/>
    <property name="Keywords" column="document_keywords" type="String"/>
    <property name="EnteredOn" column="entered_date" type="System.DateTime"/>
    <property name="Name" column="document_name" type="String"/>
    <bag name="Pages" table="Page" lazy="true" inverse="true" cascade="all">
      <key column="document_id"/>
      <one-to-many class="HomeDMSObjectModel.Page, HomeDMSObjectModel"/>
    </bag>
    <bag name="Tags" table="Document_Tag" lazy="true" inverse="true" cascade="save-update">
      <key column="document_id"/>
      <many-to-many column="tag_id" class="HomeDMSObjectModel.Tag, HomeDMSObjectModel"/>
    </bag>
  </class>

  <class name="Tag">
    <id name="Id" column="tag_id">
      <generator class="identity"/>
    </id>
    <property name="Name" column="tag_name"/>
  </class>
</hibernate-mapping> 
